package com.example.bookshop.controller.user;

import com.example.bookshop.entity.Customer;
import com.example.bookshop.result.Result;
import com.example.bookshop.service.user.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;

@RestController
@CrossOrigin
public class CustomerController {
    @Autowired
    private CustomerService customerService;
    //注册
    @RequestMapping("api/userLogin")
    public Result Login(@RequestBody Customer customer, HttpSession session){
        return customerService.Login(customer,session);
    }

    //注册
    @RequestMapping("api/register")
    public int addCustomer(@RequestBody Customer customer){
        return customerService.addCustomer(customer);
    }

    //返回个人信息
    @RequestMapping("api/getCustomer")
    public Customer getCustomer(HttpSession session){
        return customerService.getCustomer(session);
    }

}
